export default abstract class ClickBase extends cc.Component{
    protected canClick : boolean = true;
    protected down:boolean = false;

    abstract ClickDown();
    abstract ClickUp();
    abstract OnDowning(dt:number);

    protected OnDown(){
        this.down = true;
    }
    protected OnUp(){
        this.down = false;
    }

    onLoad(){
        this.node.on(cc.Node.EventType.TOUCH_START,this.ClickDown,this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL,this.ClickUp,this);
        this.node.on(cc.Node.EventType.TOUCH_END,this.ClickUp,this);
        this.node.on(cc.Node.EventType.TOUCH_START,this.OnDown,this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL,this.OnUp,this);
        this.node.on(cc.Node.EventType.TOUCH_END,this.OnUp,this);
    }

    lateUpdate(dt:number){
        if(!this.down){return;}
        this.OnDowning(dt);
    }
}